//
// Created by Jisam on 2024/6/12.
//
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define x first
#define y second
#define INF 0x3f3f3f3f
#define PII pair<int,int>
const int N = 100+10;
const int mod = 1e9+7;
int m , n;
char f[N][N];

void dfs(int x, int  y){
    f[x][y] = '*';
    for(int dx = -1; dx <= 1; dx ++){
        for(int dy = -1 ; dy <= 1 ; dy ++){
            int nx = x + dx, ny = y + dy;
            if(nx >= 0 && nx < n && ny < m && f[dx][dy] == '@' )
                dfs(nx ,ny);
        }
    }
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);

    while(cin >> n >> m){
        if( m == 0 || n == 0) break;

        memset(f ,0 , sizeof f);

        for(int i = 0 ; i < n ; i ++) cin  >> f[i];
        int ans = 0;
        for(int i  = 0 ; i < n ; i ++ )
            for(int j = 0 ; j < n ; j ++){
                if(f[i][j] == '@'){
                    ans ++;
                    dfs(i, j);
                }

            }
        cout << ans << endl;
    }
    return 0;
}